//
//  TUIGuestMessageCellData.m
//  MarryBackEnd
//
//  Created by mac on 2021/4/12.
//  Copyright © 2021 WPP. All rights reserved.
//

#import "TUIGuestMessageCellData.h"

@implementation TUIGuestMessageCellData
- (instancetype)initWithDirection:(TMsgDirection)direction
{
    if (self = [super initWithDirection:direction]) {
        
    }
    return self;
}
- (void)setCustomModel:(TUICustomModel *)customModel
{
    _customModel = customModel;
    {
        NSMutableAttributedString *titleAttributes = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"咨询礼：%@",customModel.ext.consultingStar]];
        titleAttributes.font = [UIFont systemFontOfSize:14*ADAPTER_WIDTH weight:UIFontWeightRegular];
        titleAttributes.color = rgba(34, 34, 34, 1);
        [titleAttributes setColor:rgba(102, 102, 102, 1) range:NSMakeRange(0, 3)];
        self.consultingStarAttributeStr = titleAttributes;
    }
    {
        NSMutableAttributedString *titleAttributes = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"到店礼：%@",customModel.ext.arrivalGift]];
        titleAttributes.font = [UIFont systemFontOfSize:14*ADAPTER_WIDTH weight:UIFontWeightRegular];
        titleAttributes.color = rgba(34, 34, 34, 1);
        [titleAttributes setColor:rgba(102, 102, 102, 1) range:NSMakeRange(0, 3)];
        self.arrivalGiftAttributeStr = titleAttributes;
    }
    CGFloat maxWidth = (WIDTH - 35*ADAPTER_WIDTH) - 102*ADAPTER_WIDTH - 12*ADAPTER_WIDTH - 25*ADAPTER_WIDTH;//左102 + 22(间隙和edite) 右边12
    UIFont *font = [UIFont systemFontOfSize:14*ADAPTER_WIDTH weight:UIFontWeightRegular];
    CGFloat phoneWidth = [customModel.ext.cdUserTel sizeWithFont:font].width;
    CGFloat nameWidth = [customModel.ext.cdUserName sizeWithFont:font].width;
    nameWidth = MIN(maxWidth - phoneWidth - 20*ADAPTER_WIDTH, nameWidth);
    self.userPhoneWidth = phoneWidth;
    self.userNameWidth = nameWidth;
    self.gradientWidth = MIN(self.userNameWidth + self.userPhoneWidth + 20*ADAPTER_WIDTH + 17*ADAPTER_WIDTH, maxWidth);
    
    //    self.cellLayout.messageInsets = (UIEdgeInsets){
    //        .top = 3,
    //        .bottom = 1,
    //        .left = 8,
    //    };
    self.cellLayout.messageInsets = (UIEdgeInsets){
        .top = 8,
        .bottom = 6,
    };
}
- (CGSize)contentSize
{
    return CGSizeMake(WIDTH - 35*ADAPTER_WIDTH, 165*ADAPTER_WIDTH);
}
@end
